@echo off
call setenv.bat

If "%JAVA_HOME%" == ""  goto notOkHome
IF NOT EXIST "%JAVA_HOME%" goto notOkHome

set CURRENT_DIR=%cd%
set CLASSPATH=%CLASSPATH%;%JAVA_HOME%;%CURRENT_DIR%/lib/junit-4.10.jar;.;
set COMPILEJAVA=javac
set EXECUTEJAVA=java
set JAVADOC=javadoc
set GENERATEJAR=jar
set OUTPUT_CLASS_OPTION=-d  ..\classes

IF NOT EXIST classes mkdir classes

cd src
echo Compiling Source Classes.....
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/constant/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/controller/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/datastore/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/datastore/exception/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/datastore/impl/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/dto/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/exception/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/gui/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/gui/component/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/persistence/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/privilege/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/util/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/validation/*.java
echo Source Compilation done


cd ../test
set CLASSPATH=%CLASSPATH%;%CURRENT_DIR%/classes;	

echo Compiling Test Classes.....
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/AllTests.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/controller/*.java
%COMPILEJAVA%  %OUTPUT_CLASS_OPTION% -classpath "%CLASSPATH%" -Xlint:none sg/edu/nus/iss/jass/persistence/*.java
echo Test Compilation done

echo Creating JAR file.....
cd ../classes
%GENERATEJAR% cf ../jasssystem.jar sg
echo Creating JAR file DONE.


cd ..
echo Generating Javadoc.....
%JAVADOC% -d docs src/sg/edu/nus/iss/jass/controller/JobSearchController.java   src/sg/edu/nus/iss/jass/controller/JobSeekerController.java  src/sg/edu/nus/iss/jass/persistence/JobAdvertDAO.java   src/sg/edu/nus/iss/jass/persistence/JobSeekerDAO.java   src/sg/edu/nus/iss/jass/datastore/BaseDAO.java
echo Generating Javadoc done

cd %CURRENT_DIR% 
goto end

:notOkHome
echo JAVA NOT AVAILABLE , Please set the JAVA_HOME in setenv.bat
:end	




